package org.lex.notepad.ui.action;

import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

import javax.swing.JDialog;
import javax.swing.KeyStroke;


import org.lex.awt.Location;
import org.lex.notepad.ui.preferences.NotepadPreferencesDialog;

public class PreferencesAction extends BaseNotepadAction {
	public PreferencesAction() {
		super();
		this.setName("Preferences ...");
		this.setMnemonic(KeyEvent.VK_P);
		this.setAcceleratorKey(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.ALT_MASK | InputEvent.CTRL_MASK, false));
	}

	// public void actionPerformed( ActionEvent e )
	public void actionPerformed(ActionEvent e) {
		JDialog dialog = new NotepadPreferencesDialog(notepad.getRootWindow());
		Location.moveToParentCenter(notepad.getRootWindow(), dialog);
		if (null != dialog) // ��֪Ϊɶ�������Ȼ���� NullPointerException
			dialog.setVisible(true);
	}
}
